﻿var jqgridHelpers = {
    after_submit : function (response, postdata) {
                        if (!response || response.status != 200) {
                            return [false, "An unexpected error occurred."];
                        }
                        var r = eval(response.responseText);
                        return r;
                    },
    split : function (val) {
                return val.split(/,\s*/);
            },
    extractLast : function (term) {
                    return this.split(term).pop();
                  }
}

$.fn.clearForm = function () {
    return this.each(function () {
        var type = this.type, tag = this.tagName.toLowerCase();
        if (tag == 'form')
            return $(':input', this).clearForm();
        if (type == 'text' || type == 'password' || tag == 'textarea')
            this.value = '';
        else if (type == 'checkbox' || type == 'radio')
            this.checked = false;
        else if (tag == 'select')
            this.selectedIndex = -1;
    });
};

